package app.mvp;

import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import app.mvp.base.BaseActivity;
public class MainActivity extends BaseActivity<MainPresenter> implements MainView {
//    private TextView tv_name;
//    private Button btn_getdata;
    private MainPresenterLogin mainPresenterLogin;

    @Override
    public int getLayoutResource() {
        return R.layout.activity_main;
    }

    @Override
    public void initPresenter() {
        Log.e("TAG", "initPresenter");
        mPresenter = new MainPresenter(new MainModel());
        mainPresenterLogin = new MainPresenterLogin(new MainModel());
    }

    @Override
    public void initView() {
//        tv_name = (TextView) findViewById(R.id.tv_name);
//        btn_getdata = (Button) findViewById(R.id.btn_getdata);


    }

    @Override
    public void initClick(View v) {
        switch (v.getId()) {
            case R.id.btn_getdata:
//                mPresenter.updateData();

//                mainPresenterLogin.toastUserName();


                Log.e("TAG", "点击");
                break;
            default:
        }

    }

    @Override
    public void initListener() {
//        btn_getdata.setOnClickListener(this);
        addOnClickListener(R.id.btn_getdata);

    }

    @Override
    public void attachView() {
        Log.e("TAG", "attachView");
        mPresenter.attachView(this, mActivity);
        mainPresenterLogin.attachView(this, mActivity);

    }

    @Override
    public void detachView() {
        mPresenter.detachView();
        mainPresenterLogin.detachView();

    }

    @Override
    public void init() {
        mPresenter.init();

    }

    @Override
    public void onClick(View v) {
        super.onClick(v);

    }

    @Override
    public void setData(MainModel mainModel) {
//        if (mainModel == null) {
//            tv_name.setText("默认值");
//
//        } else {
//            tv_name.setText(mainModel.getName());
//        }


    }

    @Override
    public void toastUserName(MainModel mainModel) {
        if (mainModel != null) {
            Toast.makeText(this, mainModel.getName(), Toast.LENGTH_SHORT).show();
        }

    }

    @Override
    public void showLoading() {
        Log.e("TAG", "showLoading");

    }

    @Override
    public void dismiss() {
        Log.e("TAG", "dismiss");

    }


}
